
using Core.Event;
using UnityEngine;
using UnityGameFramework.Runtime;

namespace Core.Test
{
    enum EventID : byte
    {
        ID1,
    }

    internal class TestEventManager : MonoBehaviour
    {

        void Start()
        {
            EventManager.AddListener<string>(EventID.ID1, OnEvent);
            EventManager.Dispatch(EventID.ID1, this, "1111");

            EventManager.RemoveListener<string>(EventID.ID1, OnEvent);
            EventManager.Dispatch(EventID.ID1, this, "2222");

            EventManager.AddListener(EventID.ID1, OnEventNoParam);
            EventManager.Dispatch(EventID.ID1, this);
            EventManager.RemoveListener(EventID.ID1, OnEventNoParam);
            EventManager.Dispatch(EventID.ID1, this);


            EventManager.ListenOnce(EventID.ID1, OnEventOnce);
            EventManager.Dispatch(EventID.ID1, this);
            EventManager.Dispatch(EventID.ID1, this);
        }

        private void OnEvent(object arg1, string obj)
        {
            Log.Warning("=======> OnEvent {0}", obj);
        }

        private void OnEventNoParam(object arg1)
        {
            Log.Warning("=======> OnEventNoParam");
        }

        private void OnEventOnce(object arg1)
        {
            Log.Warning("=======> OnEventOnce");
        }
    }
}